#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

/*
    给定一个区间，以及一个排好序的数组
    请你输出此区间与数组的交集的不在数组中的集合
*/


int b_find(vector<int> &v,int x){
    if(v.size()==0){
        return -1;
    }
    int l=0,r=v.size()-1;
    int m=l+(r-l)/2;   
    while(l<=r){
        m=l+(r-l)/2;
        if(v[m]<x){
            l=l+1;
        }else if(v[m]>x){
            r=r-1;
        }else{
            return m;
        }  
    }
    if(l<v.size()-1){
        return l;
    }
    return -1;
}


vector<string> helper(vector<int> &v,int l,int h){
    vector<string> ans;
    int len=v.size();
    if(len==0){
        return ans;
    }
    int ll=b_find(v,l);
    int rr=b_find(v,h);
    int reall=-1,realr=-1;
    if(ll!=-1 && rr !=-1  ){
        //1. all in bound
        reall=ll;
        realr=rr;
    }else if(ll!=-1){
        // 2. l in; r not in
        reall=l;
        realr=len-1;
    }else if(rr!=-1){
        realr=h;
        reall=0;
    }
    if(h>v[len-1]||l<v[0]){
        reall=0;
        realr=len-1;
    }


    if(reall==-1&& realr==-1){
        return ans;
    }
    // cout << reall << " " << realr <<endl;
    for(int i=reall;i<realr;i++){
        if(v[i+1]-v[i]>1){
            if(2==(v[i+1]-v[i])){
                ans.push_back(to_string(v[i+1]-1));
            }else{
                ans.push_back(to_string(max(v[i]+1,l))+"->"+to_string(min(v[i+1]-1,h)));
            }
        }
    }

}

int main(){
    vector<int> v{0,1,3,50,75};
   auto ret= helper(v,0,51);
//    auto ret= b_find(v,75);
//    cout << ret<<endl;
    for(int i=0;i<ret.size();i++){
        cout << " "<<ret[i]<< " ";
    }cout <<endl;
}

